'use strict';

module.exports = app => {
  const { INTEGER, DATE, STRING, BOOLEAN } = app.Sequelize;

  return app.model.define('token', {
    token: { type: STRING(100), primaryKey: true },
    refresh: STRING(100),
    code: {
      type: INTEGER,
      references: {
        model: app.model.Code,
        key: 'code',
      },
      onUpdate: 'CASCADE',
      onDelete: 'CASCADE',
    },
    valid: BOOLEAN,
    created_at: DATE,
    updated_at: DATE,
  });
};
